<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html lang="zh-CN" >

<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap-3.4.1-dist/css/bootstrap.css">
    <script src="${pageContext.request.contextPath}/static/bootstrap-3.4.1-dist/js/bootstrap.js"></script>
    <title>商城</title>
    <script>
        function delCollection(id){
            if(confirm("您确定要删除吗？")){
                location.href="${pageContext.request.contextPath}/CollectionServlet?action=delCollection&id="+id;
            }
        }
    </script>
</head>

<body>
<c:if test="${empty user}">
    <div class="top-nav">
        <div class="container clearf">
            <div class="left">
                <a href="${pageContext.request.contextPath}/Index.jsp" class="item">首页</a>
            </div>

            <div class="right">
                <a href="${pageContext.request.contextPath}/Register.jsp" class="item">注册/登录</a>
            </div>
        </div>
    </div>
</c:if>

<c:if test="${not empty user}">
    <div class="top-nav">
        <div class="container clearf">
            <div class="left">
                <a href="${pageContext.request.contextPath}/UserServlet?action=BackToIndex&id=${user.id}" class="item">首页</a>
            </div>

            <div class="right">
                <div class="dropdown item">
                    <a class="item">欢迎您，${user.username}</a>
                    <div class="dropdown-content">
                        <a href="${pageContext.request.contextPath}/UserServlet?action=UserInf&id=${user.id}">个人信息</a>
                        <a href="${pageContext.request.contextPath}/OrdersServlet?action=Orderselect&uid=${user.id}">我的订单</a>
                        <a href="${pageContext.request.contextPath}/CartServlet?action=IntoCart&id=${user.id}">我的购物车</a>
                        <a href="${pageContext.request.contextPath}/CollectionServlet?action=IntoCollection&id=${user.id}">我的收藏夹</a>
                        <a href="${pageContext.request.contextPath}/UserServlet?action=LogOut">退出登录</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</c:if>


<div class="container clearf">
    <div class="cat-promote">
        <div class="title">我的收藏夹</div>
        <div class="content">
        <c:forEach items="${product}" var="p" varStatus="c">
            <div class="col-2 item">
                <div class="card" style="text-align: center">
                    <a href="${pageContext.request.contextPath}/ProductServlet?action=IntoProduct&uid=${user.id}&pid=${p.productid}">
                        <img src="${pageContext.request.contextPath}/img/${p.picture}" style="height: 200px">
                        <a>${p.name}</a>
                        <h2 style="color: red">￥${p.price}</h2>
                    </a>
                </div>
                <button type="button" class="btn btn-danger" onclick="delCollection(${p.id})">删除</button>
            </div>
        </c:forEach>


        </div>
    </div>
</div>


<hr>
<div class="footer">
    <div class="container clearf">
        <div class="">© 2021  版权所有 粤ICP备11111111号 |隐私政策|用户使用协议|资质证照|知识产权</div>
    </div>
</div>

</body>

</html>
